package com.test.daily.leetcode.y2021.m10.day1013;

import java.util.ArrayList;
import java.util.List;

/**
 * @descriptions: fizzBuzz
 * @author: Tom
 * @date: 2021/10/13 下午 04:21
 * @version: 1.0
 */
public class Code01_FizzBuzz {
    public static void main(String[] args) {
        printList(fizzBuzz(15));
    }

    public static List<String> fizzBuzz(int n) {
        ArrayList<String> al = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            if (i % 15 == 0) {
                al.add(new String("FizzBuzz"));
            } else if (i % 3 == 0) {
                al.add(new String("Fizz"));
            } else if (i % 5 == 0) {
                al.add(new String("Buzz"));
            } else {
                al.add(new Integer(i).toString());
            }
        }
        return al;
    }

    public static void printList(List<String> al) {
        al.forEach(
                ele -> {
                    System.out.print(ele + " ");
                }
        );

    }
}
